package org.example.Server.controller.semester;

import lombok.extern.slf4j.Slf4j;
import org.example.Server.model.semester.SemesterDTO;
import org.example.Server.service.semester.SemesterService;
import org.example.Server.utils.ResultAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


/**
 * 教师端个人中心课堂管理
 */
@RestController
@Slf4j
@RequestMapping("/youxich/semester/personal")
public class SemesterPersonalController {
    @Autowired
    SemesterService semesterService;

    /**
     * 教师个人中心的课程显示
     *
     * @return
     */
    @GetMapping
    public ResultAPI getSemesterList(@RequestParam Integer semester_status,
                                     @RequestParam Integer tech_id) {
        return semesterService.getSemesterPersonalList(semester_status, tech_id);
    }

    /**
     * 教师个人中心课堂新建
     *
     * @param semesterDTO
     * @return
     */
    @PostMapping
    public ResultAPI addSemester(SemesterDTO semesterDTO, @RequestParam MultipartFile file) {
        return semesterService.addSemester(semesterDTO, file);
    }

    /**
     * 教师复制课堂
     *
     * @param semesterDTO
     * @return
     */
    @PostMapping("/copy")
    public ResultAPI CopySem(@RequestBody SemesterDTO semesterDTO) {
        return semesterService.CopySem(semesterDTO);
    }

    /**
     * 删除课堂
     *
     * @param semId
     * @return
     */
    @DeleteMapping("{semId}")
    public ResultAPI deleteSem(@PathVariable Integer semId) {
        return semesterService.deleteSem(semId);
    }

    /**
     * 更新课堂信息
     *
     * @param semesterDTO
     * @return
     */
    @PutMapping()
    public ResultAPI updateSem(@RequestBody SemesterDTO semesterDTO) {
        return semesterService.updateSem(semesterDTO);
    }
}
